package mysql

import "news/models"

func GetPrevPostById(id int64) (data *models.PostOrder, err error) {
	data = &models.PostOrder{}
	sqlstr := "select id, title from post where id < ? order by id desc limit 1"
	err = db.Get(data, sqlstr, id)
	if err != nil {
		return
	}
	return
}

func GetNextPostById(id int64) (data *models.PostOrder, err error) {
	data = &models.PostOrder{}
	sqlstr := "select id, title from post where id > ? order by id asc limit 1"
	err = db.Get(data, sqlstr, id)
	if err != nil {
		return
	}
	return
}
